<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * 订单表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id');
            $table->decimal('price')->comment('订单总额');
            $table->decimal('pay_price')->comment('应支付金额');
            $table->decimal('point')->comment('该订单获得的总积分');
            $table->string('consignee', 60)->nullable()->comment('收货人姓名');
            $table->string('mobile', 11)->nullable()->comment('收货人手机号');
            $table->string('address')->nullable()->comment('详细地址');
            $table->tinyInteger('pay_type')->comment('支付方式, 1为货到付款，2为在线支付，3为公司转账');
            $table->tinyInteger('type')->default(1)->comment('订单的类型，1为普通订单，2为充值');
            $table->tinyInteger('pay_status')->default(1)
                ->comment('支付状态：1未付款; 2预订单; 3付款中; 4已付款;');
            $table->tinyInteger('ship_status')->default(1)
                ->comment('商品配送情况：1未发货, 2已发货, 3已收货, 4退货');
            $table->tinyInteger('status')->default(1)
                ->comment('订单的状态：1确认, 2已取消, 3退货, 4完成, 5已评价');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
